//
//  HomePageFriendBtnsView.m
//  CToolBox
//
//  Created by crj on 16/8/29.
//  Copyright © 2016年 oyf. All rights reserved.
//

#import "YJHomePageFooterView.h"

@interface YJHomePageFooterView()

@property (nonatomic, strong) UIButton *friendBtn;
@property (nonatomic, strong) UIButton *blackBtn;
@property (nonatomic, strong) UIButton *chatBtn;

@end

@implementation YJHomePageFooterView

- (instancetype)initWithFrame:(CGRect)frame relation:(long)relation
{
    self = [super initWithFrame:frame];
    if (self) {
        _relation = relation;
        
      
        
        [self setUIWithFrame:frame];
        
       
    }
    return self;
}

- (void)setUIWithFrame:(CGRect)rect{

    if(_relation == YJHomePageFooterViewBtnTypeNone){
        
        CGRect frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
        UIButton *friendBtn = [Factory btnWithFrame:frame
                                           title:@"加为好友"
                                          target:self
                                        selector:@selector(btnAction:)];
        friendBtn.tag = YJHomePageFooterViewBtnAddFriend;
        [self addSubview:friendBtn];
        
    }else if(_relation == YJHomePageFooterViewBtnTypeFriend){
        
        
        UIButton *blackBtn = [Factory btnWithFrame:CGRectMake(0, 0, rect.size.width/2, rect.size.height)
                                              type:UIButtonTypeCustom
                                             title:@"拉黑请三思"
                                          fontSize:15
                                        titleColor:HEXCOLOR(kColorGray1, 1)
                                   backgroundColor:[UIColor whiteColor]
                                            target:self
                                          selector:@selector(btnAction:)];
        blackBtn.tag = YJHomePageFooterViewBtnMoveFriendInBlack;
        [self addSubview:blackBtn];
        
        UIButton *chatBtn = [Factory btnWithFrame:CGRectMake(rect.size.width/2, 0, rect.size.width/2, rect.size.height)
                                            title:@"发私信"
                                           target:self
                                         selector:@selector(btnAction:)];
        chatBtn.tag = YJHomePageFooterViewBtnChat;
        [self addSubview:chatBtn];
    }else if(_relation == YJHomePageFooterViewBtnTypeBlack){
        
        CGRect frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
        UIButton *friendBtn = [Factory btnWithFrame:frame
                                              title:@"取消拉黑"
                                             target:self
                                           selector:@selector(btnAction:)];
        friendBtn.tag = YJHomePageFooterViewBtnMoveFriendOutBlack;
        [self addSubview:friendBtn];

    }
    
    
    UILabel *lineView = [[UILabel alloc] init];
    lineView.frame = CGRectMake(0, 0, rect.size.width, 1);
    lineView.backgroundColor = HEXCOLOR(kColorGray7, 1);
    [self addSubview:lineView];
}

- (void)btnAction:(UIButton *)btn{
    
    NSLog(@"btn---%zi",btn.tag);
    
//    if(btn.tag == YJHomePageFooterViewBtnAdding){
//        self.isFriend = YES;
//    }
    
    if([_delegate respondsToSelector:@selector(homePageFooterViewSelectIndex:)]){
        [_delegate homePageFooterViewSelectIndex:btn.tag];
    }
}

#pragma mark - SET

- (void)setRelation:(YJHomePageFooterViewBtnType)relation{
    
    _relation = relation;
    
    for(UIView *view in self.subviews){
        [view removeFromSuperview];
    }
    
    [self setUIWithFrame:self.frame];
}



@end
